//
//  EFAddressManager.m
//  EnjogFood
//
//  Created by 王芳 on 17/5/28.
//  Copyright © 2017年 wf. All rights reserved.
//

#import "EFAddressManager.h"
#import "ICCompletePofileInfo.h"

@implementation EFAddressManager
- (instancetype)init{
    self = [super init];
    if (self) {
        self.addressArray = [NSMutableArray array];//EFMyDeliveryAddressViewItem
        self.defaultAddress = [[EFMyDeliveryAddressViewItem alloc]init];
        [self loadAccountFromCache];
    }
    return self;
}

- (void)loadAccountFromCache {
    EFMyDeliveryAddressViewItem *tempInfo = [NSKeyedUnarchiver unarchiveObjectWithFile:[self pathOfCacheFile]];
    if (tempInfo != nil) {
        self.defaultAddress = tempInfo;
    }
}


-(void)persistenceAddressManager{
    if (![NSKeyedArchiver archiveRootObject:self.defaultAddress toFile:[self pathOfCacheFile]]) {
        NSLog(@"error, cache account info failed!");
    }
}

- (NSString *)pathOfCacheFile {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
    NSString *libraryPath = [paths objectAtIndex:0];
    return [libraryPath stringByAppendingPathComponent:@"address_info.plist"];
}

@end
